package com.jishuo.nontax.bfc.service;

import com.github.pagehelper.PageHelper;
import com.jishuo.base.bean.BaseResult;
import com.jishuo.base.bean.ErrorCodeEnum;
import com.jishuo.base.bean.Pagination;
import com.jishuo.base.util.StringObject;
import com.jishuo.nontax.bean.vo.BankVO;
import com.jishuo.nontax.bean.vo.QueryBankDateVO;
import com.jishuo.nontax.bean.vo.QueryMessageVO;
import com.jishuo.nontax.bfc.dao.BankMapper;
import com.jishuo.nontax.bfc.dao.MessageSysMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 查询统计
 *
 * @auther dinggaofei
 * @Date 2023/3/20 17:50
 */
@Service
public class QueryService {
    @Resource
    private BankMapper bankMapper;
    @Resource
    private MessageSysMapper messageSysMapper;

    public List<BankVO> queryBank(BankVO bankVO, Pagination pagination) {
        if (pagination.getRows() > 0) PageHelper.startPage(pagination.getPage(), pagination.getRows());
        return bankMapper.queryBank(bankVO);
    }

    public List<QueryBankDateVO> querybankfordate(Long bankid, String paybankdt, Pagination pagination) {
        if (pagination.getRows() > 0) PageHelper.startPage(pagination.getPage(), pagination.getRows());
        return bankMapper.querybankfordate(bankid, paybankdt);
    }



    public List<QueryMessageVO> queryMessageLog(String action, String senddate, String types, Pagination pagination) {
        if (pagination.getRows() > 0) PageHelper.startPage(pagination.getPage(), pagination.getRows());
        if ("0".equals(types)) {
            return messageSysMapper.queryMessageLog(action, senddate);
        } else {
            return messageSysMapper.queryMessageSendLog(action, senddate);
        }

    }

    public BaseResult updateMessageState(Long messageid) {
        try {
            if (messageid != null && messageid != 0) {
                messageSysMapper.updateMessageState(messageid);
                messageSysMapper.updateMessageSendState(messageid);
                return new BaseResult();
            } else {
                return new BaseResult(ErrorCodeEnum.BILL_NOT_FOUND);
            }
        } catch (Exception e) {
            return new BaseResult(ErrorCodeEnum.UNKNOWN_ERR);
        }


    }
}
